home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ASME's Mechanical Engine…ing Toolkit 1997 December
/
ASME's Mechanical Engineering Toolkit 1997 December.iso
/
auto_cad
/
vol1no3.lzh
/
MOMENT.BAS
< prev
next >
Wrap
BASIC Source File
|
1986-07-18
|
3KB
|
54 lines
100 ' ********************************
110 ' * MOMENT OF INERTIA *
120 ' ********************************
130 '
140 ' Designed and implemented by:
150 ' Christopher C. Bachman
160 ' 6-15-86
170 ' THIS PROGRAM WILL EXTRACT THE X AND Y CO-ORDINATES FOR EACH CELL IN
180 ' AN AUTOCAD DXF FILE TO DETERMINE THE MOMENT OF INERTIA OF THE AREA.
190 ' THIS REQUIRES KNOWING THE CELL SIZE USED IN THE DXF FILE, AND THE
200 ' CO-ORDINATES OF THE CENTROID OF THE SECTION AREA.
210 '
220 LINE INPUT "Give the DXF filename including path and extension. ",F$
230 OPEN F$ FOR INPUT AS #1
240 LINE INPUT "Give the scale factor used with the *dots pattern. ",C$
250 CELL.SIZE# = (VAL(C$) / 16)^2
260 LINE INPUT "Give the X co-ordinate from the Centroid calculation. ",X$
270 CENTROID.X# = VAL(X$)
280 LINE INPUT "Give the Y co-ordinate from the Centroid calculation. ",Y$
290 CENTROID.Y# = VAL(Y$)
300 IF EOF(1) THEN 560
310 INPUT #1, DRAWING.ENTITY.CODE%
320 LINE INPUT #1, DRAWING.ENTITY.NAME$
330 IF DRAWING.ENTITY.NAME$ <> "LINE" THEN 300 'Test for line entities.
340 INPUT #1, DRAWING.LAYER.CODE% 'All line entities are
350 LINE INPUT #1, DRAWING.LAYER.NAME$ 'followed by layer data.
360 IF DRAWING.LAYER.NAME$ <> "0" THEN GOTO 300 'Test for lines on layer 0.
370 FOR CO.ORDINATES = 1 TO 2
380 INPUT #1, CO.ORDINATE.CODE% 'After the layer data comes
390 LINE INPUT #1, CO.ORDINATE.DATA$ 'location data for each line.
400 '
410 ' Starting X co-ordinates have a code of 10.
420 '
430 IF CO.ORDINATE.CODE% = 10 THEN X.DATA# = VAL(CO.ORDINATE.DATA$)
440 '
450 ' Starting Y co-ordinates have a code of 20.
460 '
470 IF CO.ORDINATE.CODE% = 20 THEN Y.DATA# = VAL(CO.ORDINATE.DATA$)
480 '
490 NEXT CO.ORDINATES
500 ' Accumulate moments of inertia.
510 ' Note: Additional spaces were added in lines 530 & 540.
520 ' Your program can simply rap around to the next line.
530 MOMENT.OF.INERTIA.X# = MOMENT.OF.INERTIA.X# + (CELL.SIZE#^2 / 12) + (CELL.SIZE# * (CENTROID.X# - X.DATA#)^2)
540 MOMENT.OF.INERTIA.Y# = MOMENT.OF.INERTIA.Y# + (CELL.SIZE#^2 / 12) + (CELL.SIZE# * (CENTROID.Y# - Y.DATA#)^2)
550 GOTO 300 'Loop til End of File
560 CLOSE 1 'Close Dxf file.
570 '
580 ' Print results.
590 '
600 PRINT "X CO-ORDINATE FOR MOMENT OF INERTIA = "MOMENT.OF.INERTIA.X#
610 PRINT "Y CO-ORDINATE FOR MOMENT OF INERTIA = "MOMENT.OF.INERTIA.Y#
620 END